import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams,AlertController} from 'ionic-angular';
import {LoginPage} from "../login/login";

/**
 * Generated class for the ProductDetailsPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-repository-details',
  templateUrl: 'repository-details.html',
})
export class RepositoryDetailsPage {

  selectedItem: any;
  user:any;
  loginsts:any;

  constructor(public navCtrl: NavController, public navParams: NavParams, private alertCtrl:AlertController) {
    this.selectedItem = this.navParams.get("item");
    if(this.selectedItem.typeid == '07') {
      //登录后操作
      this.loginsts = localStorage.getItem('loginsts');
      //电脑测试
      //this.loginsts = "1";
      if (!(this.loginsts == "1")) {
        this.navCtrl.push(LoginPage);
        return;
      }

      this.user = JSON.parse(localStorage.getItem('user'));
      this.user = this.user ? JSON.parse(localStorage.getItem('user')) : [];
      console.log(this.user);
      let companyid = this.user.companyid;
      if (companyid !='07') {
        let alert = this.alertCtrl.create({
            title:'提示信息',
            subTitle:'权限问题不能查看知识库详情,请使用公司域账号手机登录!',
            buttons:['确定']
          });
        alert.present();
        this.navCtrl.push(LoginPage);
        return;
      }
    }
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad RepositoryDetailsPage');
  }
  //
  // goBuy() {
  //   let options = {
  //     statusbar: {color: '#f8285c'},
  //     toolbar: {height: 44, color: '#f8285c'},
  //     title: {color: '#ffffffff', showPageTitle: true},
  //     backButton: {image: 'ios-arrow-back', imagePressed: 'ios-arrow-back-outline', align: 'left', event: 'backPressed'},
  //     backButtonCanClose: true
  //   };
  //   /*selectedItem.ClickUrl 改成收银台*/
  //   new ThemeableBrowser(this.selectedItem.ClickUrl,'_blank', options);
  // }
}
